from game.FAL.FightAgainstLandlords import FALDeck
from game.FAL.play import FALPlay
from game.FAL.play import analysis
from core.poker import poker
import random

p=FALPlay()
#玩家加入
p.join("yeihizhi")
p.join("tangjing")
p.join("other")
#发牌
p.deal()
#随机抢地主 正式的这个需要叫分
i="tangjing"

#拿地主
p.landowner(i)
for player in p.__player__:
    p.sort(p.__player__[player])
    print("\r\n\r\n{0}:".format(player))
    for item in p.__player__[player]:
        color=None
        if item.__color__==1:
            color="黑桃"
        elif item.__color__==2:
            color="红心"
        elif item.__color__==3:
            color="方块"
        elif item.__color__==4:
            color="梅花"
        print("{0}({1})".format(item.__displayname__,color),end=',')
print("\r\n")

'''
plist=[]
countg=p.getpokercount(i)
print(countg)
bb=random.randint(1,countg-1)
#print(bb)
for j in range(0,bb):
    plist.append(j)
result=False
while(p.getpokercount(i)>0):
    result=p.play(i,plist)
    if result:
        for item in p.__playlist__:
            print("\r\n牌型:{0}".format(item.__type__),end='->')
            for o in item.__playlist__:
                print(o.__displayname__,end=',')
        print("\r\n出牌后：")
        for items in p.__decklist__:
            p.sort(items[1])
            print("\r\n\r\n{0}:".format(items[0]))
            for item in items[1]:
                color=None
                if item.__color__==1:
                    color="黑桃"
                elif item.__color__==2:
                    color="红心"
                elif item.__color__==3:
                    color="方块"
                elif item.__color__==4:
                    color="梅花"
                print("{0}({1})".format(item.__displayname__,color),end=',')
            print("\r\n")
        result=False
    else:   
        plist=[]
        countg=p.getpokercount(i)
        #print("剩余：{0}".format(countg))
        if countg>1:
            bb=random.randint(0,countg-1)
            #print("随机数：{0}".format(bb))
            for j in range(0,bb):
                plist.append(j)
        else:
            plist.append(0)
'''